package com.daiqile.rxjava;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hitomi.refresh.view.FunGameRefreshView;

import java.util.ArrayList;
import java.util.List;

public class RecycleView extends AppCompatActivity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycle_view);
        RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycle_view);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);
        final RecycleAdapter adapter = new RecycleAdapter(getSome());
        recyclerView.setAdapter(adapter);
        FunGameRefreshView funGameRefreshView = (FunGameRefreshView)findViewById(R.id.refresh_hit_block);
        funGameRefreshView.setOnRefreshListener(new FunGameRefreshView.FunGameRefreshListener() {
            @Override
            public void onPullRefreshing() {
                SystemClock.sleep(3000);
            }

            @Override
            public void onRefreshComplete() {
                adapter.notifyDataSetChanged();
            }
        });


    }

    private List<Somethings> getSome() {
        List<Somethings> something= new ArrayList<>();
        for (int i = 0;i<10;i++){
            Somethings a = new Somethings("fuck");
            something.add(a);
        }
        return something;
    }

}
